<!DOCTYPE html>
<html lang="en" xmlns:th="http://www.thymeleaf.org"
      xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head lang="en">
    <meta charset="UTF-8"/>
    <title></title>
     <link th:href="@{~/static/css/common.css}" rel="stylesheet" />
</head>
<body>
	<div th:include="/common/head"></div>

	<section id="main">
		
	
		
	</section>
	
	<script type="text/javascript">
	
		var pageNo=1;
		/* 获取通知列表 */
		function noticeList(key){
			$.ajax({
				url:"/notice/list",
				type:"post",
				contentType:"application/json;charset=utf-8",
				data:{"pageNo":key},
				success:function(data){
					pageNo=data.page.currentPageNo;//更新当前页码
					$("#main").html("");//清空通知列表
					var html="";
					var nList=data.nList;//获取通知集合
				
					for(var i in nList){ 
						html+=nList[i].title;
					}
				},
				error:function(){
					//出错时回调该函数 
					alert("error");
				}
			});
		}
		noticeList(pageNo);
		/* 10秒刷新一次通知 */
		/* setInterval(noticeList(pageNo),10000);  */
		
		/* 发布通知 */
		function addNotice(){
			$.ajax({
				url:"/notice/add",
				type:"post",
				contentType:"application/json;charset=utf-8",
				data:{"id":id},
				success:function(data){
					if(data.msg=="success"){
						alert("发布成功！");
						noticeList(pageNo);
					}else{
						alert("发布失败！请重新尝试");
					}
				},
				error:function(){
					//出错时回调该函数 
					alert("出现错误！发布失败！");
				}
			});
		}
		
		/* 删除通知 */
		function delNotice(id){
			$.ajax({
				url:"/notice/delete",
				type:"post",
				contentType:"application/json;charset=utf-8",
				data:{"id":id},
				success:function(data){
					if(data.msg=="success"){
						alert("删除成功！");
						noticeList(pageNo);
					}else{
						alert("删除失败！请重新尝试");
					}
				},
				error:function(){
					//出错时回调该函数 
					alert("出现错误！删除失败！");
				}
			});
		}
	</script>

</body>
</html>